import express from 'express';
import { getUsers, getUser, login, creatUser, getUsersByFamilyId, addFamilyUserByPhone } from '../controllers/userController';
import { wxLogin } from '../controllers/weaChatLogin';  // 导入处理微信登录的控制器函数
const router = express.Router();
import { tokenVerification } from '../middlewares/tokenVerification';
// 强制将 tokenVerification 转换为 RequestHandler 类型
import { RequestHandler } from 'express';

// 获取所有用户
router.get('/users', getUsers);

// 获取单个用户
router.get('/users/:id', getUser);

// 登录接口
router.post('/login', login);

// 注册接口
router.post('/creatUser', creatUser);

// 微信登录接口
router.post('/weChatLogin', wxLogin);  // 调用控制器中的 wxLogin 函数

//根据family_id 查询成员列表
router.get('/getUsersByFamilyId', tokenVerification as RequestHandler, getUsersByFamilyId)

//添加成员
router.post('/addFamilyUserByPhone', tokenVerification as RequestHandler, addFamilyUserByPhone)

export default router;
